﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MVVMDemo
{
    public partial class UserEditFrm : Form
    {

        private CustomerModelViewModel _customerModelViewModel;
        public UserEditFrm()
        {
            InitializeComponent();
        }


        public UserEditFrm(CustomerModel customerModel)
        {
            InitializeComponent();            
            Load(customerModel);
        }

        public void Load(CustomerModel customerModel)
        {
            if (customerModel != null)
            {
                txtCustomerName.DataBindings.Add(new Binding("Text", customerModel, "CustomerName", true));
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }

}
